package org.jeecg.modules.wlhy.customer.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.wlhy.customer.entity.HyCustomerUser;
import org.jeecg.modules.wlhy.customer.mapper.HyCustomerUserMapper;
import org.jeecg.modules.wlhy.customer.service.IHyCustomerUserService;
import org.jeecg.modules.wlhy.customer.vo.SysUserCustomerUser;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @Description: 货主子账号
 * @Author: duanlikao
 * @Date:   2020-12-19
 * @Version: V1.0
 */
@Service
public class HyCustomerUserServiceImpl extends ServiceImpl<HyCustomerUserMapper, HyCustomerUser> implements IHyCustomerUserService {

    @Resource
    private HyCustomerUserMapper hyCustomerUserMapper;

    @Override
    public HyCustomerUser getInfoByUserId(String userId) {
        return hyCustomerUserMapper.getInfoByUserId(userId);
    }

    @Override
    public List <HyCustomerUser> getInfoByUserIds(String userIds) {
        List<String> idsl = Arrays.asList(userIds.split(","));
        String ids = String.format("'%s'", String.join("','", idsl));
        return hyCustomerUserMapper.getInfoByUserIds(ids);
    }

    @Override
    public List<HyCustomerUser> getByCustomer(String customerId) {

        return hyCustomerUserMapper.getByCustomer(customerId);
    }

    @Override
    public IPage<SysUserCustomerUser> getUserListByCustomerId(Page<SysUserCustomerUser> userPage, String customerId) {
        return userPage.setRecords(hyCustomerUserMapper.getUserListByCustomerId(userPage, customerId));
    }

    @Override
    public void revertLogicDeleted(List<String> hyCustomerUserIds) {
        String ids = String.format("'%s'", String.join("','", hyCustomerUserIds));

        hyCustomerUserMapper.revertLogicDeleted(ids);
    }

    @Override
    public void removeLogicDeleted(List<String> hyCustomerUserIds) {
        String ids = String.format("'%s'", String.join("','", hyCustomerUserIds));
        hyCustomerUserMapper.removeLogicDeleted(ids);
    }

    @Override
    public List<HyCustomerUser> getDeleteByUserIds(String userIds) {
        List<String> idsl = Arrays.asList(userIds.split(","));
        String ids = String.format("'%s'", String.join("','", idsl));
        return  hyCustomerUserMapper.getDeleteByUserIds(ids);
    }
}
